/*     */ package com.zimbra.cs.service.account;
/*     */ 
/*     */ import com.zimbra.common.service.ServiceException;
/*     */ import com.zimbra.common.soap.Element;
/*     */ import com.zimbra.common.util.Log;
/*     */ import com.zimbra.common.util.ZimbraLog;
/*     */ import com.zimbra.cs.account.AttributeClass;
/*     */ import com.zimbra.cs.account.AttributeManager;
/*     */ import com.zimbra.cs.account.Provisioning;
/*     */ import com.zimbra.cs.account.Provisioning.MailMode;
/*     */ import com.zimbra.cs.account.Server;
/*     */ import com.zimbra.soap.DocumentHandler;
/*     */ import java.util.HashSet;
/*     */ import java.util.Map;
/*     */ import java.util.Set;
/*     */ import javax.servlet.http.HttpServletRequest;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ public abstract class AccountDocumentHandler
/*     */   extends DocumentHandler
/*     */ {
/*     */   protected Element proxyIfNecessary(Element request, Map<String, Object> context)
/*     */     throws ServiceException
/*     */   {
/*     */     try
/*     */     {
/*  44 */       return super.proxyIfNecessary(request, context);
/*     */     }
/*     */     catch (ServiceException e) {
/*  47 */       if ("service.PROXY_ERROR".equals(e.getCode())) {
/*  48 */         return null;
/*     */       }
/*  50 */       throw e;
/*     */     }
/*     */   }
/*     */   
/*     */ 
/*     */   protected boolean checkPasswordSecurity(Map<String, Object> context)
/*     */     throws ServiceException
/*     */   {
/*  58 */     HttpServletRequest req = (HttpServletRequest)context.get("servlet.request");
/*  59 */     boolean isHttps = req.getScheme().equals("https");
/*  60 */     if (isHttps) {
/*  61 */       return true;
/*     */     }
/*     */     
/*  64 */     Server server = Provisioning.getInstance().getLocalServer();
/*  65 */     String modeString = server.getAttr("zimbraMailMode", null);
/*  66 */     if (modeString == null)
/*     */     {
/*  68 */       ZimbraLog.soap.warn("missing zimbraMailMode for checking password security, allowing the request");
/*     */       
/*  70 */       return true;
/*     */     }
/*     */     
/*  73 */     Provisioning.MailMode mailMode = Provisioning.MailMode.fromString(modeString);
/*  74 */     if ((mailMode == Provisioning.MailMode.mixed) && (!server.getBooleanAttr("zimbraMailClearTextPasswordEnabled", true)))
/*     */     {
/*  76 */       return false;
/*     */     }
/*  78 */     return true;
/*     */   }
/*     */   
/*     */   protected Set<String> getReqAttrs(Element request, AttributeClass klass) throws ServiceException {
/*  82 */     String attrsStr = request.getAttribute("attrs", null);
/*  83 */     if (attrsStr == null) {
/*  84 */       return null;
/*     */     }
/*     */     
/*  87 */     String[] attrs = attrsStr.split(",");
/*     */     
/*  89 */     Set<String> attrsOnEntry = AttributeManager.getInstance().getAllAttrsInClass(klass);
/*  90 */     Set<String> validAttrs = new HashSet();
/*     */     
/*  92 */     for (String attr : attrs) {
/*  93 */       if (attrsOnEntry.contains(attr)) {
/*  94 */         validAttrs.add(attr);
/*     */       } else {
/*  96 */         throw ServiceException.INVALID_REQUEST("requested attribute " + attr + " is not on " + klass.name(), null);
/*     */       }
/*     */     }
/*     */     
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/* 104 */     return validAttrs;
/*     */   }
/*     */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/service/account/AccountDocumentHandler.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */